<template>
  <div class='search-box pr'>
    <div class="container">
      <input type="text" ref="search" placeholder="Search...">
      <div class="search" @click="gotoSearch"></div>
    </div>
  </div>
</template>
<script>
export default {
  components: {},
  name: "",
  data() {
    return {};
  },
  methods: {
    gotoSearch(){
      this.$refs.search.focus()
    }
  },
  created() {}
};
</script>
<style lang="scss" scoped>
.search-box {
  width: 100%;
  margin: 15px;
  box-sizing: border-box;
}
@import url("https://fonts.googleapis.com/css?family=Inconsolata:700");

.container {
  position: absolute;
  width: calc(100% - 30px);
  height: 100%;
}
.container .search {
  position: absolute;
  // margin: auto;
  // top: 0;
  // right: 40px;
  // bottom: 0;
  right: 0;
  width: 40px;
  height: 40px;
  background: crimson;
  border-radius: 50%;
  transition: all 1s;
  z-index: 4;
  box-shadow: 0 0 25px 0 rgba(0, 0, 0, 0.4);
}
.container .search:hover {
  cursor: pointer;
}
.container .search::before {
  content: "";
  position: absolute;
  margin: auto;
  top: 16px;
  right: 0;
  bottom: 0;
  left: 16px;
  width: 12px;
  height: 2px;
  background: white;
  transform: rotate(45deg);
  transition: all 0.5s;
}
.container .search::after {
  content: "";
  position: absolute;
  margin: auto;
  top: -5px;
  right: 0;
  bottom: 0;
  left: -5px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid white;
  transition: all 0.5s;
}
.container input {
  font-family: "Inconsolata", monospace;
  position: absolute;
  // margin: auto;
  // top: 0;
  // right: 0;
  // bottom: 0;
  // left: 0;
  width: 0px;
  height: 40px;
  outline: none;
  border: none;
  background: crimson;
  color: white;
  text-shadow: 0 0 10px crimson;
  border-radius: 20px;
  box-shadow: 0 0 25px 0 crimson, 0 20px 25px 0 rgba(0, 0, 0, 0.2);
  transition: all 1s;
  opacity: 0;
  z-index: 5;
  font-weight: bolder;
  letter-spacing: 0.1em;
}
.container input:hover {
  cursor: pointer;
}
.container input:focus {
  width: calc(100% - 100px);
  opacity: 1;
  padding: 0 80px 0 20px;
  cursor: text;
}
.container input:focus ~ .search {
  right:-320px;
  background: #151515;
  z-index: 6;
}
.container input:focus ~ .search::before {
  top: 0;
  left: 0;
  width: 25px;
}
.container input:focus ~ .search::after {
  top: 0;
  left: 0;
  width: 25px;
  height: 2px;
  border: none;
  background: white;
  border-radius: 0%;
  transform: rotate(-45deg);
}
.container input::placeholder {
  color: white;
  opacity: 0.5;
  font-weight: bolder;
}
</style>